package net.lastcoder.ifserver.command;

import java.util.StringTokenizer;

/**
 * auth: WenYF
 * date: 2017/2/11
 */
public abstract class CommandProcessor {
    /**
     * @param str
     * @return  如果不处理，必须返回null
     */
    public abstract String process(String str);

    protected String next(StringTokenizer st) {
        if (st.hasMoreTokens()) {
            return st.nextToken();
        } else {
            return "";
        }
    }

    protected String nextRemain(StringTokenizer st) {
        String str = "";
        while (st.hasMoreTokens()) {
            str = str + " " + st.nextToken();
        }
        return str.trim();
    }

    protected StringBuilder assemble(StringBuilder sb, String str) {
        sb.append(str).append("\n");
        return sb;
    }
}
